package logic

import (
	"context"
	"shopconnect/model/mysql"

	"shopconnect/shoprpc/internal/svc"
	"shopconnect/shoprpc/shoprpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShopAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewShopAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShopAddLogic {
	return &ShopAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ShopAddLogic) ShopAdd(in *shoprpc.ShopAddRequest) (*shoprpc.ShopAddResponse, error) {
	// todo: add your logic here and delete this line
	products := mysql.Products{
		Img:   in.Img,
		Video: in.Video,
		Name:  in.Name,
		Nums:  in.Nums,
		Intro: in.Intro,
		Price: float64(in.Price),
	}
	mysql.DB.Debug().Create(&products)
	return &shoprpc.ShopAddResponse{Id: int64(products.ID)}, nil
}
